
Ext.define('PackageManager.controller.PackageController', {
    extend: 'Ext.app.Controller',

    stores: [
        'ComponentStore',
        'StaticDataStore',
        'PackageStore',
        'PackageStoreFull'
    ],

    views: [
        'PackageView'
    ],

    models: [
        'Component',
        'Package',
        'PackageModelFull'
    ],
    init: function() {
        this.control({
            'button[action=changeState]': {
                click: this.changeState
            }

        })
    },
    changeState: function() {
        var dataStage = Ext.getStore('PackageStore').first().data.stage;
        var record = Ext.getStore('PackageStore').first();
        if (dataStage == 'PRE_COMMITTEE') {
            record.set('stage', 'IN_COMMITTEE');
        }
        else if (dataStage == 'IN_COMMITTEE') {
            record.set('stage', 'PRE_COMMITTEE');
        }
        Ext.getCmp('griddy').chooseState();
    }
});
